from django.db import models
from django.utils.timezone import now

from apps.gateway.models import Gateway


class OneLineHistory(models.Model):
    key = models.CharField(db_column="c_key", max_length=32, verbose_name=u"主键", primary_key=True, blank=False,
                           null=False)
    gateway_id = models.IntegerField(db_column='c_gateway_id', verbose_name="通讯ID", null=False)
    is_connected = models.BooleanField(db_column="c_is_connected", default=False)
    create_date = models.DateTimeField(db_column="c_create_date", default=now)

    class Meta:
        db_table = "t_online_history"
        verbose_name = "上线历史记录"
        verbose_name_plural = verbose_name
        ordering = ["-create_date"]
